package com.lbg.drug.controller;


import com.lbg.drug.commont.untils.PageUtils;
import com.lbg.drug.commont.untils.R;
import com.lbg.drug.dto.FactPage;
import com.lbg.drug.entity.DrugFacts;
import com.lbg.drug.mapper.DrugFactsMapper;
import com.lbg.drug.service.DrugFactsService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 药品信息表1
 * </p>
 *
 * @author lbg
 * @since 2022-04-26
 */
@Api(value="药品信息表",tags={"药品信息表"})
@RestController
@RequestMapping("/drug-facts")
public class DrugFactsController {


    @Autowired
    private DrugFactsService drugFactsService;


    @PostMapping("/getDrugs")
    public R getDrugs(@RequestBody FactPage factPage) {
        PageUtils dact = drugFactsService.getDact(factPage);
        return R.ok().put("dact",dact);
    }

    @PostMapping("/upDrugs")
    public R upDrugs(@RequestBody DrugFacts drugFacts) {
      drugFactsService.update(drugFacts);
        return R.ok();
    }

    @GetMapping("/remove")
    public R remove(String id) {
       drugFactsService.delete(id);
        return R.ok();
    }

    @PostMapping("/add")
    public R add(@RequestBody DrugFacts drugFacts) {
        String id = drugFactsService.intsert(drugFacts);
        return R.ok().put("id",id);
    }



}

